﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
    public class Coord3
    {
        public float X;
        public float Y;
        public float Z;

        public Coord3()
        {
            X = 0f;
            Y = 0f;
            Z = 0f;

        }

        public Coord3(float x, float y, float z)
        {
            X = x;
            Y = y;
            Z = z;
        }

        public Coord3(System.IO.BinaryReader reader)
        {
            X = reader.ReadSingle();
            Y = reader.ReadSingle();
            Z = reader.ReadSingle();
        }

        public Coord3(byte[] bytes)
        {
            X = BitConverter.ToSingle(bytes, 0);
            Y = BitConverter.ToSingle(bytes, 4);
            Z = BitConverter.ToSingle(bytes, 8);
        }

        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.AppendLine(string.Format("{0} {1} = {2}", "float", "X", X));
            sb.AppendLine(string.Format("{0} {1} = {2}", "float", "Y", Y));
            sb.AppendLine(string.Format("{0} {1} = {2}", "float", "Z", Z));

            return sb.ToString();
        }

        public string ToString(string xname, string yname, string zname)
        {
            var sb = new StringBuilder();
            sb.AppendLine(string.Format("{0} {1} = {2}", xname, "X", X));
            sb.AppendLine(string.Format("{0} {1} = {2}", yname, "Y", Y));
            sb.AppendLine(string.Format("{0} {1} = {2}", zname, "Z", Z));

            return sb.ToString();
        }
    }
}
